home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / ucrasm27.zip / TEST.ZIP / TEST.ASM < prev    next >
Assembly Source File  |  1991-12-07  |  43KB  |  2,741 lines

  1.         include        stdlib.a
  2.         includelib     stdlib.lib
  3. ;****************************************************************************
  4. ;
  5. ; T  E  S  T       S  U  I  T  E      F  O  R
  6. ;
  7. ;
  8. ; R  A  N  D  Y      H  Y  D  E ' S     S  T  A  N  D  A  R  D
  9. ;
  10. ; L  I  B  R  A  R  Y     F  O  R     A  S  S  E  M  B  L  Y
  11. ;
  12. ; L  A  N  G  U  A  G  E     P  R  O  G  R  A  M  M  E  R  S
  13. ;
  14. ;****************************************************************************
  15. ;
  16. ;
  17. ; Global variables go here:
  18. ;
  19. StdData        segment    para public 'sldata'
  20.         extrn    fpacc:byte
  21. StdData        ends
  22. ;
  23. ;
  24. dseg        segment    para public 'data'
  25. i        dw    -4321
  26. pi        dd    i
  27. u        dw    2345
  28. pu        dd    u
  29. l        dd    -1234567890
  30. pl        dd    l
  31. ul        dd    987654321
  32. pul        dd    ul
  33. ;
  34. ps        dd    s
  35. s        db    "Printf string",0
  36. TestString0    db    "This string gets printed by puts!",cr,lf,0
  37. TestString1    db    "This string gets used by the STRxxx Routines",cr,lf,0
  38. TestString2    db    "gets",0
  39. TestString3    db    "Hello there",0
  40. TestString4    db    "THIS STRING GETS USED BY THE STRXXX ROUTINES",cr,lf,0
  41. TestString5    db    "all lower case",cr,lf,0
  42. TestString6    db    "Clear out this string",0
  43. StringSet1    db    "Tabcdefghijklmnopqrst ",0
  44. StringSet2    db    "uvwxyz!",0
  45. InsStrSrc    db    "Insert This",0
  46. InsStrDest    db    "--><--",0
  47. RevStr1        db    "012345",0
  48. RevStr2        db    "0123456",0
  49. RevStr3        db    "1",0
  50. RevStr4        db    0
  51. buffer        db    256 dup (?)
  52. buffer2        db    256 dup (?)
  53. sfstr1        db    "1 -1 1 65000 100000 -100000 1 4000000000 0abc x",0
  54. sfstr2        db    "1, 2",0
  55. hex1        db    "12ab",0
  56. int1        db    "-12345",0
  57. int2        db    "65000",0
  58. lint1        db    "-2000000000",0
  59. lint2        db    "4000000000",0
  60. i1        dw    ?
  61. i2        dw    ?
  62. u1        dw    ?
  63. u2        dw    ?
  64. l1        dd    ?
  65. l2        dd    ?
  66. ul1        dd    ?
  67. ul2        dd    ?
  68. h1        dw    ?
  69. c1        db    ?
  70. c2        db    '!'
  71. MemAvail    dw    ?
  72. ;
  73. ;
  74. ;
  75. ; Allocate some character sets down here
  76. ;
  77.         set    charset, cs2, cs3, cs4
  78. ;
  79. ;
  80. ; Floating point values:
  81. ;
  82. SPConst1    dd    1.0
  83. SPConst10    dd    10.25
  84. SPConst100    dd    100.50
  85. SPConst1000    dd    1000.75
  86. SPConst10000    dd    10000.22
  87. SPConst100000    dd    100000.44
  88. SPConst1000000    dd    1000000.66
  89. SPConst123456    dd    123456.88
  90. SPConst65432    dd    65432.11
  91. SPConst9876    dd    9876.33
  92. SPConst192    dd    192.55
  93. SPConst38    dd    38.77
  94. SPConst9    dd    9.99
  95. ;
  96. DPConst1    dq    1.0
  97. DPConst10    dq    10.25
  98. DPConst100    dq    100.50
  99. DPConst1000    dq    1000.75
  100. DPConst10000    dq    10000.22
  101. DPConst100000    dq    100000.44
  102. DPConst1000000    dq    123456789012345678.66
  103. DPConst123456    dq    123456.88
  104. DPConst65432    dq    65432.11
  105. DPConst9876    dq    9876.33
  106. DPConst192    dq    192.55
  107. DPConst38    dq    38.77
  108. DPConst9    dq    9.99
  109. ;
  110. EPConst1    dt    1.0
  111. EPConst10    dt    10.25
  112. EPConst100    dt    100.50
  113. EPConst1000    dt    1000.75
  114. EPConst10000    dt    10000.22
  115. EPConst100000    dt    100000.44
  116. EPConst1000000    dt    123456789012345678901.66
  117. EPConst123456    dt    123456.88
  118. EPConst65432    dt    65432.11
  119. EPConst9876    dt    9876.33
  120. EPConst192    dt    192.55
  121. EPConst38    dt    38.77
  122. EPConst9    dt    9.99
  123. ;
  124. ;
  125. ;
  126. HexTestString    db    1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
  127. ;
  128. dseg        ends
  129. ;
  130. ;
  131. ;
  132. ;
  133. cseg        segment    para public 'code'
  134.         assume    cs:cseg, ds:dseg
  135. ;
  136. ;
  137. lesi        macro    adrs
  138.         mov     di, seg adrs
  139.         mov    es, di
  140.         mov    di, offset adrs
  141.         endm
  142. ;
  143. ldxi        macro    adrs
  144.         mov    dx, seg adrs
  145.         mov    si, offset adrs
  146.         endm
  147. ;
  148. ; Variables that wind up being used by the standard library routines.
  149. ; The MemInit routine uses "PSP" and "zzzzzzseg" labels.  They must be
  150. ; present if you intend to use getenv, MemInit, malloc, and free.
  151. ;
  152. ;
  153.         public    PSP
  154. PSP        dw    ?
  155. ;
  156. cr        equ    13
  157. lf        equ    10
  158. ;
  159. ;
  160. ; Main is the main program.  Program execution always begins here.
  161. ;
  162. Main        proc
  163.         mov    cs:PSP, es        ;Save pgm seg prefix
  164.         mov    ax, seg dseg        ;Set up the segment registers
  165.         mov    ds, ax
  166.         mov    es, ax
  167.         mov    dx, 0            ;Allocate all available RAM.
  168.         MemInit
  169.         mov    MemAvail, cx
  170.         printf
  171.         db    "There are %x paragraphs of memory available."
  172.         db    cr,lf,lf,0
  173.         dd    MemAvail
  174. ;
  175. ;
  176. ;
  177. ;***************************************************************************
  178. ;
  179. ; Test the Argc and Argv functions:
  180. ;
  181.         print
  182.         db    "This routine has ",0
  183.         argc
  184.         mov    ax, cx
  185.         puti
  186.         print
  187.         db    " command line arguments",cr,lf,0
  188. ;
  189. ;
  190. ;***************************************************************************
  191. ;
  192. ; Test the ToHex (Intel Hex string conversion) routine:
  193. ;
  194.         lesi    HexTestString
  195.         mov    cx, 16
  196.         ToHex
  197.         print
  198.         db    "Intel hex string is ",0
  199.         puts
  200.         free
  201. ;
  202. ;
  203. ;***************************************************************************
  204. ;
  205. ; Test the floating point routines.
  206. ;
  207.         print
  208.         db    "Testing itof:",cr,lf,0
  209. ;
  210.         mov    ax, 1
  211. Testitoflp:    push    ax
  212.         mov    cx, 6
  213.         putisize
  214.         print
  215.         db    " = ",0
  216.         itof
  217.         mov    ax, 209h
  218.         ftoam
  219.         puts
  220.         free
  221.         call    putfpacc
  222.         putcr
  223.         pop    ax
  224.         cmp    ax, 10000
  225.         jg    TestItofDone
  226.         cmp    ax, -10000
  227.         jl    TestItofDone
  228.         mov    cx, ax
  229.         mov    bx, -10
  230.         mul    bx
  231.         add    ax, cx
  232.         jmp       Testitoflp
  233. ;
  234. TestItofDone:   putcr
  235. ;
  236. ;----
  237. ;
  238.         print
  239.         db    "Testing utof:",cr,lf,0
  240. ;
  241.         mov    ax, 1
  242. Testutoflp:    push    ax
  243.         mov    cx, 5
  244.         putusize
  245.         print
  246.         db    " = ",0
  247.         utof
  248.         mov    ax, 209h
  249.         ftoam
  250.         puts
  251.         free
  252.         call    putfpacc
  253.         putcr
  254.         pop    ax
  255.         cmp    ax, 10000
  256.         ja    TestUtofDone
  257.         mov    cx, ax
  258.         mov    bx, 10
  259.         mul    bx
  260.         add    ax, cx
  261.         jmp       Testutoflp
  262. ;
  263. TestUtofDone:   putcr
  264. ;
  265. ;----
  266. ;
  267.         print
  268.         db    "Testing ltof:",cr,lf,0
  269. ;
  270.         mov    ax, 1
  271.         mov    dx, 0
  272. Testltoflp:    push    ax
  273.         push    dx
  274.         mov    cx, 11
  275.         putlsize
  276.         print
  277.         db    " = ",0
  278.         ltof
  279.         mov    ax, 20eh
  280.         ftoam
  281.         puts
  282.         free
  283.         call    putfpacc
  284.         putcr
  285.         pop    dx
  286.         pop    ax
  287.         push    dx
  288.         cmp    ax, 0ca00h        ;low(1e9)
  289.         sbb    dx, 3b9ah        ;high(1e9)
  290.         pop    dx
  291.         ja    TestLtofDone
  292.         shl    ax, 1            ;Multiply by 10.
  293.         rcl    dx, 1
  294.         mov    si, ax
  295.         mov    di, dx
  296.         shl    ax, 1
  297.         rcl    dx, 1
  298.         shl    ax, 1
  299.         rcl    dx, 1
  300.         add    ax, si
  301.         adc    dx, di
  302.         jmp       Testltoflp
  303. ;
  304. TestLtofDone:   putcr
  305. ;
  306.         mov    ax, -1
  307.         mov    dx, -1
  308. Testltoflp2:    push    ax
  309.         push    dx
  310.         mov    cx, 11
  311.         putlsize
  312.         print
  313.         db    " = ",0
  314.         ltof
  315.         mov    ax, 20eh
  316.         ftoam
  317.         puts
  318.         free
  319.         call    putfpacc
  320.         putcr
  321.         pop    dx
  322.         pop    ax
  323.         push    dx
  324.         push    ax
  325.         sub    ax, 3600h        ;low(-1e9)
  326.         sbb    dx, 0c465h        ;high(1e9)
  327.         pop    ax
  328.         pop    dx
  329.         jb    TestLtofDone2
  330.         shl    ax, 1            ;Multiply by 10.
  331.         rcl    dx, 1
  332.         mov    si, ax
  333.         mov    di, dx
  334.         shl    ax, 1
  335.         rcl    dx, 1
  336.         shl    ax, 1
  337.         rcl    dx, 1
  338.         add    ax, si
  339.         adc    dx, di
  340.         jmp       Testltoflp2
  341. ;
  342. TestLtofDone2:  putcr
  343. ;
  344.         print
  345.         db    cr,lf
  346.         db    "Testing ULTOF",cr,lf,0
  347. ;
  348.         mov    ax, 1
  349.         mov    dx, 0
  350. Testultoflp2:    push    ax
  351.         push    dx
  352.         mov    cx, 11
  353.         putulsize
  354.         print
  355.         db    " = ",0
  356.         ultof
  357.         mov    ax, 20eh
  358.         ftoam
  359.         puts
  360.         free
  361.         call    putfpacc
  362.         putcr
  363.         pop    dx
  364.         pop    ax
  365.         push    dx
  366.         push    ax
  367.         sub    ax, 3600h        ;low(-1e9)
  368.         sbb    dx, 0c465h        ;high(1e9)
  369.         pop    ax
  370.         pop    dx
  371.         ja    TestuLtofDone2
  372.         shl    ax, 1            ;Multiply by 10.
  373.         rcl    dx, 1
  374.         mov    si, ax
  375.         mov    di, dx
  376.         shl    ax, 1
  377.         rcl    dx, 1
  378.         shl    ax, 1
  379.         rcl    dx, 1
  380.         add    ax, si
  381.         adc    dx, di
  382.         jmp       Testultoflp2
  383. ;
  384. TestuLtofDone2:  putcr
  385. ;
  386. ;
  387. ;----
  388. ;
  389.         print
  390.         db    "Testing LSFPA:",cr,lf,0
  391. ;
  392.         lesi    SPConst1
  393.         lsfpa
  394.         print
  395.         db    "       1.0 =",0
  396.         mov    ax, 20bh
  397.         ftoam
  398.         puts
  399.         putcr
  400.         free
  401. ;
  402.         lesi    SPConst10
  403.         lsfpa
  404.         print
  405.         db    "     10.25 =",0
  406.         mov    ax, 20bh
  407.         ftoam
  408.         puts
  409.         putcr
  410.         free
  411. ;
  412.         lesi    SPConst100
  413.         lsfpa
  414.         print
  415.         db    "    100.50 =",0
  416.         mov    ax, 20bh
  417.         ftoam
  418.         puts
  419.         putcr
  420.         free
  421. ;
  422.         lesi    SPConst1000
  423.         lsfpa
  424.         print
  425.         db    "   1000.75 =",0
  426.         mov    ax, 20bh
  427.         ftoam
  428.         puts
  429.         putcr
  430.         free
  431. ;
  432.         lesi    SPConst10000
  433.         lsfpa
  434.         print
  435.         db    "  10000.22 =",0
  436.         mov    ax, 20bh
  437.         ftoam
  438.         puts
  439.         putcr
  440.         free
  441. ;
  442.         lesi    SPConst100000
  443.         lsfpa
  444.         print
  445.         db    "  10000.44 =",0
  446.         mov    ax, 20bh
  447.         ftoam
  448.         puts
  449.         putcr
  450.         free
  451. ;
  452.         lesi    SPConst1000000
  453.         lsfpa
  454.         print
  455.         db    "1000000.66 =",0
  456.         mov    ax, 20bh
  457.         ftoam
  458.         puts
  459.         print
  460.         db    "  Note: only 6-7 significant digits.",cr,lf,0
  461.         free
  462. ;
  463.         lesi    SPConst123456
  464.         lsfpa
  465.         print
  466.         db    " 123456.88 =",0
  467.         mov    ax, 20bh
  468.         ftoam
  469.         puts
  470.         putcr
  471.         free
  472. ;
  473.         lesi    SPConst65432
  474.         lsfpa
  475.         print
  476.         db    "  65432.11 =",0
  477.         mov    ax, 20bh
  478.         ftoam
  479.         puts
  480.         putcr
  481.         free
  482. ;
  483.         lesi    SPConst9876
  484.         lsfpa
  485.         print
  486.         db    "   9876.33 =",0
  487.         mov    ax, 20bh
  488.         ftoam
  489.         puts
  490.         putcr
  491.         free
  492. ;
  493.         lesi    SPConst192
  494.         lsfpa
  495.         print
  496.         db    "    192.55 =",0
  497.         mov    ax, 20bh
  498.         ftoam
  499.         puts
  500.         putcr
  501.         free
  502. ;
  503.         lesi    SPConst38
  504.         lsfpa
  505.         print
  506.         db    "     38.77 =",0
  507.         mov    ax, 20bh
  508.         ftoam
  509.         puts
  510.         putcr
  511.         free
  512. ;
  513.         lesi    SPConst9
  514.         lsfpa
  515.         print
  516.         db    "      9.99 =",0
  517.         mov    ax, 20bh
  518.         ftoam
  519.         puts
  520.         putcr
  521.         putcr
  522.         free
  523. ;
  524. ;
  525. ;----
  526. ;
  527.         print
  528.         db    "Testing LDFPA:",cr,lf,0
  529. ;
  530.         lesi    DPConst1
  531.         ldfpa
  532.         print
  533.         db    "       1.0 =",0
  534.         mov    ax, 20bh
  535.         ftoam
  536.         puts
  537.         putcr
  538.         free
  539. ;
  540.         lesi    DPConst10
  541.         ldfpa
  542.         print
  543.         db    "     10.25 =",0
  544.         mov    ax, 20bh
  545.         ftoam
  546.         puts
  547.         putcr
  548.         free
  549. ;
  550.         lesi    DPConst100
  551.         ldfpa
  552.         print
  553.         db    "    100.50 =",0
  554.         mov    ax, 20bh
  555.         ftoam
  556.         puts
  557.         putcr
  558.         free
  559. ;
  560.         lesi    DPConst1000
  561.         ldfpa
  562.         print
  563.         db    "   1000.75 =",0
  564.         mov    ax, 20bh
  565.         ftoam
  566.         puts
  567.         putcr
  568.         free
  569. ;
  570.         lesi    DPConst10000
  571.         ldfpa
  572.         print
  573.         db    "  10000.22 =",0
  574.         mov    ax, 20bh
  575.         ftoam
  576.         puts
  577.         putcr
  578.         free
  579. ;
  580.         lesi    DPConst100000
  581.         ldfpa
  582.         print
  583.         db    "  10000.44 =",0
  584.         mov    ax, 20bh
  585.         ftoam
  586.         puts
  587.         putcr
  588.         free
  589. ;
  590.         lesi    DPConst1000000
  591.         ldfpa
  592.         print
  593.         db    "123456789012345678.66 =",0
  594.         mov    ax, 216h
  595.         ftoam
  596.         puts
  597.         print
  598.         db    "  Note: only 17 sig. digits.",cr,lf,0
  599.         free
  600. ;
  601.         lesi    DPConst123456
  602.         ldfpa
  603.         print
  604.         db    " 123456.88 =",0
  605.         mov    ax, 20bh
  606.         ftoam
  607.         puts
  608.         putcr
  609.         free
  610. ;
  611.         lesi    DPConst65432
  612.         ldfpa
  613.         print
  614.         db    "  65432.11 =",0
  615.         mov    ax, 20bh
  616.         ftoam
  617.         puts
  618.         putcr
  619.         free
  620. ;
  621.         lesi    DPConst9876
  622.         ldfpa
  623.         print
  624.         db    "   9876.33 =",0
  625.         mov    ax, 20bh
  626.         ftoam
  627.         puts
  628.         putcr
  629.         free
  630. ;
  631.         lesi    DPConst192
  632.         ldfpa
  633.         print
  634.         db    "    192.55 =",0
  635.         mov    ax, 20bh
  636.         ftoam
  637.         puts
  638.         putcr
  639.         free
  640. ;
  641.         lesi    DPConst38
  642.         ldfpa
  643.         print
  644.         db    "     38.77 =",0
  645.         mov    ax, 20bh
  646.         ftoam
  647.         puts
  648.         putcr
  649.         free
  650. ;
  651.         lesi    DPConst9
  652.         ldfpa
  653.         print
  654.         db    "      9.99 =",0
  655.         mov    ax, 20bh
  656.         ftoam
  657.         puts
  658.         putcr
  659.         putcr
  660.         free
  661. ;
  662. ;
  663.         print
  664.         db    "Testing lefap:",cr,lf,0
  665. ;
  666.         lesi    EPConst1
  667.         lefpa
  668.         print
  669.         db    "       1.0 =",0
  670.         mov    ax, 20bh
  671.         ftoam
  672.         puts
  673.         putcr
  674.         free
  675. ;
  676.         lesi    EPConst10
  677.         lefpa
  678.         print
  679.         db    "     10.25 =",0
  680.         mov    ax, 20bh
  681.         ftoam
  682.         puts
  683.         putcr
  684.         free
  685. ;
  686.         lesi    EPConst100
  687.         lefpa
  688.         print
  689.         db    "    100.50 =",0
  690.         mov    ax, 20bh
  691.         ftoam
  692.         puts
  693.         putcr
  694.         free
  695. ;
  696.         lesi    EPConst1000
  697.         lefpa
  698.         print
  699.         db    "   1000.75 =",0
  700.         mov    ax, 20bh
  701.         ftoam
  702.         puts
  703.         putcr
  704.         free
  705. ;
  706.         lesi    EPConst10000
  707.         lefpa
  708.         print
  709.         db    "  10000.22 =",0
  710.         mov    ax, 20bh
  711.         ftoam
  712.         puts
  713.         putcr
  714.         free
  715. ;
  716.         lesi    EPConst100000
  717.         lefpa
  718.         print
  719.         db    "  10000.44 =",0
  720.         mov    ax, 20bh
  721.         ftoam
  722.         puts
  723.         putcr
  724.         free
  725. ;
  726.         lesi    EPConst1000000
  727.         lefpa
  728.         print
  729.         db    "123456789012345678901.66 =",0
  730.         mov    ax, 219h
  731.         ftoam
  732.         puts
  733.         print
  734.         db    "  Note: only 17 sig. digits.",cr,lf,0
  735.         free
  736. ;
  737.         lesi    EPConst123456
  738.         lefpa
  739.         print
  740.         db    " 123456.88 =",0
  741.         mov    ax, 20bh
  742.         ftoam
  743.         puts
  744.         putcr
  745.         free
  746. ;
  747.         lesi    EPConst65432
  748.         lefpa
  749.         print
  750.         db    "  65432.11 =",0
  751.         mov    ax, 20bh
  752.         ftoam
  753.         puts
  754.         putcr
  755.         free
  756. ;
  757.         lesi    EPConst9876
  758.         lefpa
  759.         print
  760.         db    "   9876.33 =",0
  761.         mov    ax, 20bh
  762.         ftoam
  763.         puts
  764.         putcr
  765.         free
  766. ;
  767.         lesi    EPConst192
  768.         lefpa
  769.         print
  770.         db    "    192.55 =",0
  771.         mov    ax, 20bh
  772.         ftoam
  773.         puts
  774.         putcr
  775.         free
  776. ;
  777.         lesi    EPConst38
  778.         lefpa
  779.         print
  780.         db    "     38.77 =",0
  781.         mov    ax, 20bh
  782.         ftoam
  783.         puts
  784.         putcr
  785.         free
  786. ;
  787.         lesi    EPConst9
  788.         lefpa
  789.         print
  790.         db    "      9.99 =",0
  791.         mov    ax, 20bh
  792.         ftoam
  793.         puts
  794.         putcr
  795.         putcr
  796.         free
  797. ;
  798. ;
  799.         print
  800.         db    "Testing lefapl:",cr,lf,0
  801. ;
  802.         lefpal
  803.         dt    1.0
  804.         print
  805.         db    "       1.0 =",0
  806.         mov    ax, 20bh
  807.         ftoam
  808.         puts
  809.         putcr
  810.         free
  811. ;
  812.         lefpal
  813.         dt    10.25
  814.         print
  815.         db    "     10.25 =",0
  816.         mov    ax, 20bh
  817.         ftoam
  818.         puts
  819.         putcr
  820.         free
  821. ;
  822.         lefpal
  823.         dt    100.50
  824.         print
  825.         db    "    100.50 =",0
  826.         mov    ax, 20bh
  827.         ftoam
  828.         puts
  829.         putcr
  830.         free
  831. ;
  832.         lefpal
  833.         dt    1000.75
  834.         print
  835.         db    "   1000.75 =",0
  836.         mov    ax, 20bh
  837.         ftoam
  838.         puts
  839.         putcr
  840.         free
  841. ;
  842.         lefpal
  843.         dt    10000.22
  844.         print
  845.         db    "  10000.22 =",0
  846.         mov    ax, 20bh
  847.         ftoam
  848.         puts
  849.         putcr
  850.         free
  851. ;
  852.         lefpal
  853.         dt    100000.44
  854.         print
  855.         db    "  10000.44 =",0
  856.         mov    ax, 20bh
  857.         ftoam
  858.         puts
  859.         putcr
  860.         free
  861. ;
  862.         lefpal
  863.         dt    123456789012345678901.66
  864.         print
  865.         db    "123456789012345678901.66 =",0
  866.         mov    ax, 219h
  867.         ftoam
  868.         puts
  869.         print
  870.         db    "  Note: only 17 sig. digits.",cr,lf,0
  871.         free
  872. ;
  873.         lefpal
  874.         dt    123456.88
  875.         print
  876.         db    " 123456.88 =",0
  877.         mov    ax, 20bh
  878.         ftoam
  879.         puts
  880.         putcr
  881.         free
  882. ;
  883.         lefpal
  884.         dt    65432.11
  885.         print
  886.         db    "  65432.11 =",0
  887.         mov    ax, 20bh
  888.         ftoam
  889.         puts
  890.         putcr
  891.         free
  892. ;
  893.         lefpal
  894.         dt    9876.33
  895.         print
  896.         db    "   9876.33 =",0
  897.         mov    ax, 20bh
  898.         ftoam
  899.         puts
  900.         putcr
  901.         free
  902. ;
  903.         lefpal
  904.         dt    192.55
  905.         print
  906.         db    "    192.55 =",0
  907.         mov    ax, 20bh
  908.         ftoam
  909.         puts
  910.         putcr
  911.         free
  912. ;
  913.         lefpal
  914.         dt    38.77
  915.         print
  916.         db    "     38.77 =",0
  917.         mov    ax, 20bh
  918.         ftoam
  919.         puts
  920.         putcr
  921.         free
  922. ;
  923.         lefpal
  924.         dt    9.99
  925.         print
  926.         db    "      9.99 =",0
  927.         mov    ax, 20bh
  928.         ftoam
  929.         puts
  930.         putcr
  931.         putcr
  932.         free
  933. ;
  934. ;
  935. ;***************************************************************************
  936. ;
  937. ; Test the StrRev and StrRev2 routines here.
  938. ;
  939.         print
  940.         db    "Testing StrRev:",cr,lf,0
  941.         lesi    RevStr1
  942.         strrev
  943.         puts
  944.         putcr
  945.         strrev
  946.         puts
  947.         putcr
  948.                 putcr
  949. ;
  950.         lesi    RevStr2
  951.         strrev
  952.         puts
  953.         putcr
  954.         strrev
  955.         puts
  956.         putcr
  957.                 putcr
  958. ;
  959.         lesi    RevStr3
  960.         strrev
  961.         puts
  962.         putcr
  963.         strrev
  964.         puts
  965.         putcr
  966.                 putcr
  967. ;
  968.         lesi    RevStr4
  969.         strrev
  970.         puts
  971.         putcr
  972.         strrev
  973.         puts
  974.         putcr
  975. ;
  976. ;
  977.         print
  978.         db    "Testing StrRev2:",cr,lf,0
  979.         lesi    RevStr1
  980.         strrevm
  981.         puts
  982.         putcr
  983.         free
  984. ;
  985.         lesi    RevStr2
  986.         strrevm
  987.         puts
  988.         putcr
  989.         free
  990. ;
  991.         lesi    RevStr3
  992.         strrevm
  993.         puts
  994.         putcr
  995.         free
  996. ;
  997.         lesi    RevStr4
  998.         strrevm
  999.         puts
  1000.         putcr
  1001.         free
  1002.         putcr
  1003. ;
  1004. ;
  1005. ;***************************************************************************
  1006. ;
  1007. ; Test the STRINS and STRDEL routines here.
  1008. ;
  1009.         print
  1010.         db    "Testing StrDel:",cr,lf,0
  1011.         ldxi    buffer
  1012.         lesi    InsStrDest
  1013.         strcpy
  1014.         mov    ax, 2
  1015.         mov    cx, ax
  1016.         strdel
  1017.         puts
  1018.         putcr
  1019. ;
  1020.         ldxi    buffer
  1021.         lesi    InsStrDest
  1022.         strcpy
  1023.         mov    ax, 20
  1024.         mov    cx, 2
  1025.         strdel
  1026.         puts
  1027.         putcr
  1028. ;
  1029.         print
  1030.         db    "Testing StrDel2:",cr,lf,0
  1031.         lesi    InsStrDest
  1032.         mov    ax, 2
  1033.         mov    cx, ax
  1034.         strdelm
  1035.         puts
  1036.         putcr
  1037.         free
  1038. ;
  1039.         lesi    InsStrDest
  1040.         mov    ax, 20
  1041.         mov    cx, 2
  1042.         strdelm
  1043.         puts
  1044.         putcr
  1045.         free
  1046. ;
  1047.         print
  1048.         db    "Testing StrInsl:",cr,lf,0
  1049.         ldxi    buffer
  1050.         lesi    InsStrDest
  1051.         strcpy
  1052. ;
  1053.         mov    cx, 3
  1054.         strinsl
  1055.         db    "Hi there",0
  1056.         puts
  1057.         putcr
  1058. ;
  1059.         print
  1060.         db    "Testing StrIns2l:",cr,lf,0
  1061.         lesi    InsStrDest
  1062.         mov    cx, 3
  1063.         strinsml
  1064.         db    "Ho ho ho!",0
  1065.         puts
  1066.         putcr
  1067.         free
  1068. ;
  1069.         lesi    InsStrDest
  1070.         mov    cx, 100
  1071.         strinsml
  1072.         db    "and a bottle of rum!",cr,lf,0
  1073.         puts
  1074.         putcr
  1075.         free
  1076. ;
  1077.         print
  1078.         db    "Testing STRINS2:",cr,lf,0
  1079.         lesi    InsStrDest
  1080.         ldxi    InsStrSrc
  1081.         mov    cx, 3
  1082.         strinsm
  1083.         jnc    GoodStrins2
  1084.         print
  1085.         db    "Could not allocate memory for StrInsm",cr,lf,0
  1086.         jmp    short BadStrins2
  1087. ;
  1088. GoodStrins2:    puts
  1089.         putcr
  1090.         free
  1091. ;
  1092. BadStrIns2:    lesi    InsStrDest
  1093.         ldxi    InsStrSrc
  1094.         mov    cx, 100
  1095.         strinsm
  1096.         jnc    GoodSI2
  1097.         print
  1098.         db    "Strinsm:memory allocation error",cr,lf,0
  1099.         jmp    short BSI2
  1100. ;
  1101. GoodSI2:    puts
  1102.         putcr
  1103.         free
  1104. ;
  1105. BSI2:        print
  1106.         db    "Testing STRINS:",cr,lf,0
  1107.         lesi    InsStrDest
  1108.         ldxi    InsStrSrc
  1109.         mov    cx, 3
  1110.         strins
  1111.         puts
  1112.         putcr
  1113.         lesi    InsStrDest
  1114.         ldxi    InsStrSrc
  1115.         mov    cx, 100
  1116.         strins
  1117.         puts
  1118.         putcr
  1119. ;
  1120. ;
  1121. ;***************************************************************************
  1122. ;
  1123. ; Test the character set routines down here:
  1124. ;
  1125.         print  
  1126.         db    "Testing RangeSet:",cr,lf,0
  1127.         mov    al, 'A'
  1128.         mov    ah, 'F'
  1129.         lesi    CharSet
  1130.         rangeset
  1131.         print
  1132.         db    "Chars in set: ",0
  1133.         call    PrintSet
  1134. ;
  1135.         print
  1136.         db    cr,lf,lf,"Testing addstr, addstrl:",cr,lf,0
  1137.         lesi    cs2
  1138.         ldxi    StringSet2
  1139.         addstr
  1140.         addstrl
  1141.         db    "aAbBcCdDeEfF",0
  1142.         print
  1143.         db    "Chars in set: ",0
  1144.         call    PrintSet
  1145. ;
  1146.         print
  1147.         db    cr,lf,lf,"Testing rmvstr, rmvstrl:",cr,lf,0
  1148.         lesi    cs2
  1149.         ldxi    StringSet2
  1150.         rmvstr
  1151.         rmvstrl
  1152.         db    "ABCDEF",0
  1153.         print
  1154.         db    "Chars in set: ",0
  1155.         call    PrintSet
  1156. ;
  1157.         print
  1158.         db    cr,lf,lf,"Testing addchar/rmvchar:",cr,lf,0
  1159.         lesi    cs2
  1160.         mov    al, 'A'
  1161.         addchar
  1162.         mov    al, 'a'
  1163.         rmvchar
  1164.         print
  1165.         db    "Chars in set: ",0
  1166.         call    PrintSet
  1167. ;
  1168.         print
  1169.         db    cr,lf,lf,"Testing emptyset:",cr,lf,0
  1170.         emptyset
  1171.         print
  1172.         db    "Chars in set: ",0
  1173.         call    PrintSet
  1174. ;
  1175.         print
  1176.         db    cr,lf,lf,"Testing member:",cr,lf,0
  1177.         addstrl
  1178.         db    "ABCDEF",0
  1179.         mov    al, 'A'
  1180.         member
  1181.         jne    NotInSet1
  1182.         print
  1183.         db    "A was not in the set",0
  1184.         jmp    short NIS1
  1185. ;
  1186. NotInSet1:    print
  1187.         db    "A is in the set",0
  1188. NIS1:        putcr
  1189.         mov    al, "G"
  1190.         member
  1191.         jne    NotInSet2
  1192.         print
  1193.         db    "G is not in the set",0
  1194.         jmp    short NIS2
  1195. ;
  1196. NotInSet2:    print
  1197.         db    "G is in the set",0
  1198. NIS2:        putcr
  1199. ;
  1200.         print
  1201.         db    cr,lf,lf,"Testing copyset:",cr,lf,0
  1202.         mov    dx, es
  1203.         mov    si, di
  1204.         lesi    cs3
  1205.         copyset
  1206.         print
  1207.         db    "Value in cs3: ",0
  1208.         call    Printset
  1209. ;
  1210.         print    
  1211.         db    cr,lf,lf,"Testing unionset:",cr,lf,0
  1212.         addstrl
  1213.         db    "ABCDEFuvwxyz",0
  1214.         ldxi    cs2
  1215.         setunion
  1216.         print
  1217.         db    "Chars in set: ",0
  1218.         call    Printset
  1219. ;
  1220.         print
  1221.         db    cr,lf,lf,"Testing set difference",cr,lf,0
  1222.         ldxi    cs2
  1223.         setdifference
  1224.         print
  1225.         db    "Chars in set: ",0
  1226.         call    PrintSet
  1227. ;
  1228. ;
  1229. ;
  1230. ;***************************************************************************
  1231. ;
  1232. ; Test the STRxxx routines here.
  1233. ;
  1234. ;
  1235. ;*Strspan
  1236. ;
  1237.         print
  1238.         db    cr,lf,lf,"Testing strspan:",cr,lf,0
  1239. ;
  1240.         lesi    TestString1
  1241.         ldxi    StringSet1
  1242.         strspan
  1243.         mov    i1, cx
  1244.         printf
  1245.         db    "TestString1 contains a character not found in "
  1246.         db    "StringSet1 at position %d\n\n",0
  1247.         dd    i1
  1248. ;
  1249. ;
  1250. ;*Strspanl
  1251. ;
  1252.         print
  1253.         db    "Testing strspanl:",cr,lf,0
  1254. ;
  1255.         lesi    TestString1
  1256.         strspanl
  1257.         db    "Tabcdefghijklmnopqrst ",0
  1258.         mov    i1, cx
  1259.         printf
  1260.         db    "TestString1 contains a character not found in "
  1261.         db    "the set at position %d\n\n",0
  1262.         dd    i1
  1263. ;
  1264. ;
  1265. ;*Strcspan
  1266. ;
  1267.         print
  1268.         db    "Testing strcspan:",cr,lf,0
  1269. ;
  1270.         lesi    TestString1
  1271.         ldxi    StringSet2
  1272.         strcspan
  1273.         mov    i1, cx
  1274.         printf
  1275.         db    "TestString1 contains a character found in "
  1276.         db    "StringSet2 at position %d\n\n",0
  1277.         dd    i1
  1278. ;
  1279. ;
  1280. ;*Strcspanl
  1281. ;
  1282.         print
  1283.         db    "Testing strcspanl:",cr,lf,0
  1284. ;
  1285.         lesi    TestString1
  1286.         strcspanl
  1287.         db    "uvwxyz!",0
  1288.         mov    i1, cx
  1289.         printf
  1290.         db    "TestString1 contains a character not found in "
  1291.         db    "the set at position %d\n\n",0
  1292.         dd    i1
  1293. ;
  1294. ;
  1295. ;*Strset, Strset2
  1296. ;
  1297.         print
  1298.         db    "Testing Strset",cr,lf,0
  1299. ;
  1300.         lesi    TestString6
  1301.         mov    al, '*'
  1302.         strset
  1303.         puts
  1304. ;
  1305. ;
  1306.         print
  1307.         db    cr,lf,lf,"Testing StrSetm:",cr,lf,0
  1308.         mov    cx, 32
  1309.         mov    al, '#'
  1310.         strsetm
  1311.         puts
  1312.         free
  1313.         putcr
  1314.         putcr
  1315. ;
  1316. ;
  1317. ;*Strupr, Strupr2
  1318. ;
  1319.         printf
  1320.         db    "Testing Strupr:\n"
  1321.         db    "Before: %s",0
  1322.         dd    TestString5
  1323.         lesi    TestString5
  1324.         strupr
  1325.         printf
  1326.         db    "After: %s",0
  1327.         dd    TestString5
  1328. ;
  1329. ;
  1330. ;*Strlwr, Strlwr2
  1331. ;
  1332.         printf
  1333.         db    cr,lf,"Testing Strlwr:\n"
  1334.         db    "Before: %s",0
  1335.         dd    TestString5
  1336.         lesi    TestString5
  1337.         strlwr
  1338.         printf
  1339.         db    "After: %s",0
  1340.         dd    TestString5
  1341. ;
  1342. ;
  1343. ;
  1344. ;*Strcmp, Strcmpl
  1345. ;
  1346.         print
  1347.         db    "Testing Strcmp",cr,lf,0
  1348. ;
  1349.         lesi    TestString1
  1350.         ldxi    TestString1
  1351.         strcmp
  1352.         jne    Sne1
  1353.         print
  1354.         db    "TestString1 == TestString1",cr,lf,0
  1355.         jmp    short s2
  1356. ;
  1357. Sne1:        print
  1358.         db    "TestString1 <> TestString1",cr,lf,0
  1359. ;
  1360. s2:        ldxi    TestString0
  1361.         strcmp
  1362.         jb    IsBelow
  1363.         ja    IsAbove
  1364.         printf
  1365.         db    "'%s' is equal to '%s'\n",0
  1366.         dd    TestString1, TestString0
  1367.         jmp    short s3
  1368. ;
  1369. IsBelow:    printf
  1370.         db    "%s is less than \n%s\n",0
  1371.         dd    TestString1, TestString0
  1372.         jmp    short s3
  1373. ;
  1374. IsAbove:    printf
  1375.         db    "%s is greater than \n%s\n",0
  1376.         dd    TestString1, TestString0
  1377. ;
  1378. S3:
  1379. ;
  1380.         print
  1381.         db    cr,lf,"Testing Strcmpl",cr,lf,0
  1382. ;
  1383.         lesi    TestString2
  1384.         strcmpl
  1385.         db    "gets",0
  1386.         jne    Sne1a
  1387.         print
  1388.         db    "TestString2 == 'gets'",cr,lf,0
  1389.         jmp    short s2a
  1390. ;
  1391. Sne1a:        print
  1392.         db    "TestString2 <> 'gets'",cr,lf,0
  1393. ;
  1394. s2a:        lesi    TestString2
  1395.         strcmpl
  1396.         db    "itsa",0
  1397.         jb    IsBelowa
  1398.         ja    IsAbovea
  1399.         printf
  1400.         db    "'%s' is equal to 'itsa'\n",0
  1401.         dd    TestString2
  1402.         jmp    short s3a
  1403. ;
  1404. IsBelowa:    printf
  1405.         db    "'%s' is less than 'itsa'\n",0
  1406.         dd    TestString2
  1407.         jmp    short s3a
  1408. ;
  1409. IsAbovea:    printf
  1410.         db    "'%s' is greater than 'itsa'\n",0
  1411.         dd    TestString2
  1412. ;
  1413. S3a:
  1414. ;
  1415. ;
  1416. ;*Stricmp, Stricmpl
  1417. ;
  1418.         print
  1419.         db    cr,lf,"Testing Stricmp",cr,lf,0
  1420. ;
  1421.         lesi    TestString1
  1422.         ldxi    TestString4
  1423.         stricmp
  1424.         jne    Sne1c
  1425.         print
  1426.         db    "TestString1 == TestString4",cr,lf,0
  1427.         jmp    short s2c
  1428. ;
  1429. Sne1c:        print
  1430.         db    "TestString1 <> TestString4",cr,lf,0
  1431. ;
  1432. s2c:        lesi    TestString1
  1433.         ldxi    TestString4
  1434.         stricmp
  1435.         jb    IsBelowc
  1436.         ja    IsAbovec
  1437.         printf
  1438.         db    "'%s' is equal to '%s'\n",0
  1439.         dd    TestString1, TestString4
  1440.         jmp    short s3c
  1441. ;
  1442. IsBelowc:    printf
  1443.         db    "'%s' is less than '%s'\n",0
  1444.         dd    TestString1, TestString4
  1445.         jmp    short s3c
  1446. ;
  1447. IsAbovec:    printf
  1448.         db    "'%s' is greater than '%s'\n",0
  1449.         dd    TestString1, TestString4
  1450. ;
  1451. S3c:
  1452. ;
  1453. ;
  1454.         print
  1455.         db    "Testing Stricmpl",cr,lf,0
  1456. ;
  1457.         lesi    TestString2
  1458.         stricmpl
  1459.         db    "GETS",0
  1460.         jne    Sne1d
  1461.         print
  1462.         db    "TestString2 == 'gets'",cr,lf,0
  1463.         jmp    short s2d
  1464. ;
  1465. Sne1d:        print
  1466.         db    "TestString2 <> 'gets'",cr,lf,0
  1467. ;
  1468. s2d:        lesi    TestString2
  1469.         strcmpl
  1470.         db    "itsa",0
  1471.         jb    IsBelowd
  1472.         ja    IsAboved
  1473.         printf
  1474.         db    "'%s' is equal to 'itsa'\n",0
  1475.         dd    TestString2
  1476.         jmp    short s3d
  1477. ;
  1478. IsBelowd:    printf
  1479.         db    "'%s' is less than 'itsa'\n",0
  1480.         dd    TestString2
  1481.         jmp    short s3d
  1482. ;
  1483. IsAboved:    printf
  1484.         db    "'%s' is greater than 'itsa'\n",0
  1485.         dd    TestString2
  1486. ;
  1487. S3d:
  1488. ;
  1489. ;
  1490. ;*Strcpy
  1491. ;
  1492.         lesi    TestString1
  1493.         ldxi    Buffer
  1494.         strcpy
  1495.         puts
  1496. ;
  1497. ;*Strcpyl
  1498. ;
  1499.         print
  1500.         db    "Testing Strcpyl:",cr,lf,0
  1501. ;
  1502.         ldxi    Buffer
  1503.         strcpyl
  1504.         db    "This is an strcpyl string",cr,lf,0
  1505.         puts
  1506.         ldxi    Buffer2
  1507.         strcpy
  1508.         puts
  1509. ;
  1510. ;*Strdup
  1511. ;
  1512.         lesi    TestString1
  1513.         strdup          
  1514.         puts
  1515.         free
  1516. ;
  1517. ;*Strdupl
  1518. ;
  1519.         print
  1520.         db    "Testing Strdupl:",cr,lf,0
  1521. ;
  1522.         strdupl
  1523.         db    "This string is for strdupl",cr,lf,0
  1524.         puts
  1525.         free
  1526. ;
  1527. ;*Strlen
  1528. ;
  1529.         lesi    s
  1530.         strlen
  1531.         mov    i1, cx
  1532.         printf
  1533.         db    "Length of string: '%s' is %d\n",0
  1534.         dd    s, i1
  1535. ;
  1536. ;*Strcat
  1537. ;
  1538.         print
  1539.         db      "Testing strcat:",cr,lf,0
  1540. ;
  1541.         lesi    Buffer
  1542.         strcpyl
  1543.         db    "Test String 1 --",0
  1544.         ldxi    TestString1
  1545.         strcat
  1546.         puts
  1547. ;
  1548. ;*Strcatl
  1549. ;
  1550.         print
  1551.         db      "Testing strcatl:",cr,lf,0
  1552. ;
  1553.         lesi    Buffer
  1554.         strcpyl
  1555.         db    "Strcatl test --",0
  1556.         strcatl
  1557.         db    "More stuff for Strcatl",cr,lf,0
  1558.         puts
  1559. ;
  1560. ;*Strcat2
  1561. ;
  1562.         print
  1563.         db    "Testing strcatm:",cr,lf,0
  1564. ;
  1565.         lesi    TestString1
  1566.         ldxi    TestString0
  1567.         strcatm
  1568.         puts
  1569.         free
  1570. ;
  1571.         print
  1572.         db    "Testing strcatml:",cr,lf,0
  1573. ;
  1574.         lesi    TestString1
  1575.         strcatml
  1576.         db    "Appended string",cr,lf,0
  1577.         puts
  1578.         free
  1579. ;
  1580. ;*Strchar
  1581. ;                     
  1582.         lesi    TestString1
  1583.         mov    al, 'a'
  1584.         StrChr
  1585.         pushf
  1586.         mov    i1, cx
  1587.         printf
  1588.         db    "Testing strchr:",cr,lf
  1589.         db    "Searching for 'a' in '%s'\n"
  1590.         db    "Found it at position %d\n",0
  1591.         dd    TestString1, i1
  1592.         popf
  1593.         jnc    FndIt1
  1594.         print
  1595.         db    "Could not find character in string.",cr,lf,0
  1596. ;
  1597. FndIt1:        lesi    TestString1
  1598.         mov    al, 'T'
  1599.         StrChr
  1600.         pushf
  1601.         mov    i1, cx
  1602.         printf
  1603.         db    "Testing strchr:",cr,lf
  1604.         db    "Searching for 'T' in '%s'\n"
  1605.         db    "Found it at position %d\n",0
  1606.         dd    TestString1, i1
  1607.         popf
  1608.         jnc    FndIt2
  1609.         print
  1610.         db    "Could not find character in string.",cr,lf,0
  1611. FndIt2:
  1612. ;
  1613. ;
  1614. ;*Strstr
  1615. ;
  1616.         print
  1617.         db    "Testing strstr:",cr,lf,0
  1618. ;
  1619.         lesi    TestString1
  1620.         ldxi    TestString2
  1621.         strstr
  1622.         jc    NotFnd2
  1623.         mov    i1, cx
  1624.         printf
  1625.         db    "Found substring at position %i\n",0
  1626.         dd    i1
  1627.         jmp    short FndIt3
  1628. ;
  1629. NotFnd2:    print
  1630.         db    "Didn't find substring #1.",cr,lf,0
  1631. ;
  1632. FndIt3:        ldxi    TestString3
  1633.         strstr
  1634.         jc    NotFnd3
  1635.         print
  1636.         db    "Error, found a string which isn't present!",cr,lf,0
  1637. ;
  1638. NotFnd3:
  1639. ;
  1640. ;
  1641. ;*Strstrl
  1642. ;
  1643.         print
  1644.         db    "Testing strstrl:",cr,lf,0
  1645. ;
  1646.         lesi    TestString1
  1647.         strstrl
  1648.         db    "gets",0
  1649.         jc    NotFnd2a
  1650.         mov    i1, cx
  1651.         printf
  1652.         db    "Found substring at position %i\n",0
  1653.         dd    i1
  1654.         jmp    short FndIt3a
  1655. ;
  1656. NotFnd2a:    print
  1657.         db    "Didn't find substring #1.",cr,lf,0
  1658. ;
  1659. FndIt3a:    strstrl
  1660.         db    "Hello There",0
  1661.         jc    NotFnd3a
  1662.         print
  1663.         db    "Error, found a string which isn't present!",cr,lf,0
  1664. ;
  1665. NotFnd3a:
  1666. ;     
  1667. ;
  1668. ;
  1669. ;
  1670.         putcr
  1671.         putcr
  1672. ;
  1673. ;***************************************************************************
  1674. ;
  1675. ; Test IsAlNum, IsDigit, IsAlpha, IsLower, IsUpper, and IsxDigit here:
  1676. ;
  1677.         print
  1678.         db    "Testing IsAlNum, IsDigit, IsAlpha, IsLower, "
  1679.         db    "IsUpper, and IsXDigit",cr,lf,0
  1680. ;
  1681.         mov    cx, 26
  1682.         mov    al, 'Z'
  1683.         mov    ah, 'z'
  1684. TstAlphaLp:    IsAlNum
  1685.         jne    yALNumFail
  1686.         IsAlpha
  1687.         jne    ALFail
  1688.         IsUpper
  1689.         jne    UprFail
  1690.         cmp    al, 'F'
  1691.         ja    NotHex
  1692.         IsXDigit
  1693.         jne    XFail
  1694. ;
  1695. NotHex:        xchg    al, ah
  1696.         IsAlNum
  1697. yALNumFail:    jne    AlNumFail
  1698.         IsAlpha
  1699.         jne    ALFail
  1700.         IsLower
  1701.         jne    LwrFail
  1702.         cmp    al, 'f'
  1703.         ja    NotHex2
  1704.         IsXDigit
  1705.         jne    XFail
  1706. ;
  1707. NotHex2:    xchg    al, ah
  1708.         dec    al
  1709.         dec    ah
  1710.         loop    TstAlphaLp
  1711. ;
  1712.         mov    cx, 10
  1713.         mov    al, '9'
  1714. TstDigLp:    IsDigit
  1715.         jne    DigitFail
  1716.         IsAlNum
  1717.         jne    AlNumFail
  1718.         IsXDigit
  1719.         jne    XFail
  1720.         dec    al
  1721.         loop    TstDigLp
  1722.         jmp    short TestBad
  1723. ;
  1724. ALNumFail:    jmp    short xALNumFail
  1725. ALFail:        jmp    short xALFail
  1726. UprFail:    jmp    xUprFail
  1727. LwrFail:    jmp    xLwrFail
  1728. XFail:        jmp    xXFail
  1729. DigitFail:    jmp    xDigitFail
  1730. ;
  1731. TestBad:    mov    al, '1'
  1732.         IsAlpha
  1733.         je    ALFail
  1734.         IsLower
  1735.         je    LwrFail
  1736.         IsUpper
  1737.         je    UprFail
  1738.         mov    al, '!'
  1739.         IsDigit
  1740.         je    DigitFail
  1741.         IsAlNum
  1742.         je    AlNumFail
  1743.         IsXDigit
  1744.         je    XFail
  1745.         jmp    TestSPrintf
  1746. ;
  1747. xALNumFail:    print
  1748.         db    "IsALNum has failed",cr,lf,0
  1749.         jmp    TestSPrintf
  1750. ;
  1751. xALFail:    print
  1752.         db    "IsAlpha has failed",cr,lf,0
  1753.         jmp    short TestSPrintf
  1754. ;
  1755. xUprFail:    print
  1756.         db    "IsUpper has failed",cr,lf,0
  1757.         jmp    short TestSPrintf
  1758. ;
  1759. xLwrFail:    print
  1760.         db    "IsLower has failed",cr,lf,0
  1761.         jmp    short TestSPrintf
  1762. ;
  1763. xXFail:        print
  1764.         db    "IsXDigit has failed",cr,lf,0
  1765.         jmp    short TestSPrintf
  1766. ;
  1767. xDigitFail:    print
  1768.         db    "IsDigit has failed",cr,lf,0
  1769. ;
  1770. ;***************************************************************************
  1771. ;
  1772. ; Testing sprintf and sprintfm here.
  1773. ;
  1774. TestSPrintf:    sprintfm
  1775.         db    "I= %i, I='%10i', I=%^i",cr,lf
  1776.         db    "U= %u",cr,lf,0
  1777.         dd    i,i,pi,u
  1778.         puts
  1779.         free
  1780. ;
  1781.         lesi    Buffer
  1782.         sprintf
  1783.         db    "I= %i, I='%10i', I=%^i",cr,lf
  1784.         db    "U= %u",cr,lf,0
  1785.         dd    i,i,pi,u
  1786.         puts
  1787. ;
  1788. ;***************************************************************************
  1789. ;
  1790. ; Testing various ITOxx routines here.
  1791. ;
  1792.         mov    ax, -1234
  1793.         itoam
  1794.         print
  1795.         db    "ITOAM: -1234 is ",0
  1796.         puts
  1797.         putcr
  1798.         free            ;Free allocated storage.
  1799. ;
  1800. ;-----
  1801. ;
  1802.         lesi    buffer
  1803.         itoa
  1804.         print
  1805.         db    "ITOA: -1234 is ",0
  1806.         puts
  1807.         putcr
  1808. ;
  1809. ;-----
  1810. ;
  1811.         lesi    buffer
  1812.         itoa2
  1813.         itoa2
  1814.         lesi    buffer
  1815.         printf
  1816.         db    "ITOA2: -1234-1234 is %s\n",0
  1817.         dd    buffer
  1818. ;
  1819. ;-----
  1820. ;
  1821.         mov    ax, 43210
  1822.         utoam
  1823.         print
  1824.         db    "UTOAM: 43210 is ",0
  1825.         puts
  1826.         putcr
  1827.         free            ;Free allocated storage.
  1828. ;
  1829. ;-----
  1830. ;
  1831.         lesi    buffer
  1832.         mov    ax, 43210
  1833.         utoa
  1834.         print
  1835.         db    "UTOA: 43210 is ",0
  1836.         puts
  1837.         putcr
  1838. ;
  1839. ;-----
  1840. ;
  1841.         lesi    buffer
  1842.         utoa2
  1843.         utoa2
  1844.         printf
  1845.         db    "UTOA2: 4321043210 is %s\n",0
  1846.         dd    buffer
  1847. ;
  1848. ;-----
  1849. ;
  1850.         lesi    buffer
  1851.         mov    ax, 0ABCDh
  1852.         htoa
  1853.         print
  1854.         db    "HTOA: 0cdh is ",0
  1855.         puts
  1856.         putcr
  1857.         mov    ax, 0ABCDh
  1858.         htoam
  1859.         print
  1860.         db    "HTOAM: 0cdh is ",0
  1861.         puts
  1862.         putcr
  1863.         free            ;Free allocated storage.
  1864. ;
  1865. ;-----
  1866. ;
  1867.         lesi    buffer
  1868.         mov    ax, 0ABCDh
  1869.         wtoa
  1870.         print
  1871.         db    "WTOA: 0abcdh is ",0
  1872.         puts
  1873.         putcr
  1874.         mov    ax, 0ABCDh
  1875.         wtoam
  1876.         print
  1877.         db    "WTOAM: 0abcdh is ",0
  1878.         puts
  1879.         putcr
  1880.         free            ;Free allocated storage.
  1881. ;
  1882. ;-----
  1883. ;
  1884.         mov    ax, -1234
  1885.         mov    dx, 0ffffh
  1886.         ltoam
  1887.         print
  1888.         db    "LTOAM: -1234 is ",0
  1889.         puts
  1890.         putcr
  1891.         free
  1892. ;
  1893. ;-----
  1894. ;
  1895.         mov    ax, 1234
  1896.         mov    dx, 0
  1897.         ultoam
  1898.         print
  1899.         db    "ULTOAM: 1234 is ",0
  1900.         puts
  1901.         putcr
  1902.         free
  1903. ;
  1904. ;
  1905. ;***************************************************************************
  1906. ;
  1907. ; Testing memory management routines here:
  1908. ;
  1909.         mov    cx, 256
  1910.         malloc
  1911.         IsPtr
  1912.         jnc    ValidPtr
  1913.         print
  1914.         db    "This is not a valid ptr (1)",cr,lf,0
  1915.         jmp    short x1
  1916. ;
  1917. ValidPtr:    print
  1918.         db    "Malloc returned a valid ptr",cr,lf,0
  1919. ;
  1920. x1:        inc    di
  1921.         IsPtr
  1922.         jc    InvalidPtr
  1923.         print
  1924.         db    "Incrementing a pointer didn't make it invalid",cr,lf,0
  1925.         jmp    short x2
  1926. ;
  1927. InvalidPtr:    print
  1928.         db    "Incrementing a pointer makes it invalid",cr,lf,0
  1929. ;
  1930. x2:        IsInHeap
  1931.         jc    BadIsIn
  1932.         print
  1933.         db    "Although incrementing it leaves it in the heap",cr,lf,0
  1934.         jmp    short x3
  1935. ;
  1936. BadIsIn:    print
  1937.         db    "Incrementing the pointer moved it out of the heap"
  1938.         db    cr,lf,0
  1939. ;
  1940. x3:        dec    di
  1941.         free
  1942.         jnc    GoodFree
  1943.         print
  1944.         db    "Free returned an error",cr,lf,0
  1945.         jmp    short x4
  1946. ;
  1947. GoodFree:    print
  1948.         db    "FREE did its job.",cr,lf,0
  1949. ;
  1950. x4:        mov    cx, 512
  1951.         malloc
  1952.         mov    cx, 256
  1953.         realloc
  1954.         jnc    GoodRealloc
  1955.         print
  1956.         db    "Realloc screwed up!",cr,lf,0
  1957.         jmp    x5
  1958. ;
  1959. GoodRealloc:    DupPtr
  1960.         free
  1961.         jnc    GF1
  1962.         print
  1963.         db    "Free choked after DupPtr",cr,lf,0
  1964.         jmp    short x5
  1965. ;
  1966. GF1:        free
  1967.         jnc    GF2
  1968.         print
  1969.         db    "Free choked after second call.",cr,lf,0
  1970.         jmp    short x5
  1971. ;
  1972. GF2:        free
  1973.         jc    x5
  1974.         print
  1975.         db    "Free DIDN'T return an error when it was "
  1976.         db    "supposed to.",cr,lf,0
  1977. ;
  1978. x5:
  1979. ;
  1980. ;
  1981. ;****************************************************************************
  1982. ;
  1983. ; Testing the ISIZE and LSIZE routines here:
  1984. ;
  1985.         mov    ax, -12345
  1986.         isize
  1987.         print
  1988.         db    "Size of -12345 (isize) is ",0
  1989.         puti
  1990.         mov    ax, 1234
  1991.         usize
  1992.         print
  1993.         db    cr,lf,"Size of 1234 (usize) is ",0
  1994.         puti
  1995. ;
  1996.         mov    dx, 0ffffh
  1997.         mov    ax, -12345
  1998.         lsize
  1999.         print
  2000.         db    cr,lf,"Size of -12345 (lsize) is ",0
  2001.         puti
  2002.         mov    ax, 1234
  2003.         xor    dx, dx
  2004.         ulsize
  2005.         print
  2006.         db    cr,lf,"Size of 1234 (ulsize) is ",0
  2007.         puti
  2008.         putcr
  2009. ;
  2010. ;****************************************************************************
  2011. ;
  2012. ; Test the "ATOxx" routines here.
  2013. ;
  2014.         print
  2015.         db    "Testing ATOH: ",0
  2016.         lesi    hex1
  2017.         atoh
  2018.         putw
  2019.         mov    al, ' '
  2020.         putc
  2021. ;
  2022.         atoh2
  2023.         putw
  2024.         putcr
  2025. ;
  2026.         print
  2027.         db    "Testing ATOI: ",0
  2028.         lesi    int1
  2029.         atoi
  2030.         puti
  2031.         mov    al, ' '
  2032.         putc
  2033.         atoi2
  2034.         puti
  2035.         putcr
  2036. ;
  2037.         print
  2038.         db    "Testing ATOU: ",0
  2039.         lesi    int2
  2040.         atou
  2041.         putu
  2042.         mov    al, ' '
  2043.         putc
  2044.         atou2
  2045.         putu
  2046.         putcr
  2047. ;
  2048.         print
  2049.         db    "Testing ATOL: ",0
  2050.         lesi    lint1
  2051.         atol
  2052.         putl
  2053.         mov    al, ' '
  2054.         putc
  2055.         atol2
  2056.         putl
  2057.         putcr
  2058. ;
  2059.         print
  2060.         db    "Testing ATOUL: ",0
  2061.         lesi    lint2
  2062.         atoul
  2063.         putul
  2064.         mov    al, ' '
  2065.         putc
  2066.         atoul2
  2067.         putul
  2068.         putcr
  2069. ;
  2070. ;
  2071. ;****************************************************************************
  2072. ;
  2073. ; Test SCANF here:
  2074. ;
  2075.         printf
  2076.         db    "Enter some text: ",0
  2077.         scanf
  2078.         db    "%s",0
  2079.         dd    buffer
  2080.         print
  2081.         db    "You entered: ",0
  2082.         lesi    buffer
  2083.         puts
  2084.         putcr
  2085. ;
  2086. ; Test SSCANF here:
  2087. ;
  2088.         printf
  2089.         db    "Before, c1=%c, c2=%c\n",0
  2090.         dd    c1,c2
  2091. ;
  2092.         lesi    sfstr1
  2093.         sscanf
  2094.         db    "%i %d %u %u %ld %li %lu %lu %x %c",0
  2095.         dd    i1,i2,u1,u2,l1,l2,ul1,ul2,h1,c1
  2096. ;
  2097.         printf
  2098.         db    "Values input by sscanf:\n"
  2099.         db    "i1=%d, i2=%d\n"
  2100.         db    "u1=%u, u2=%u\n"
  2101.         db    "l1=%ld, l2=%ld\n"
  2102.         db    "ul1=%lu, ul2=%lu\n"
  2103.         db    "h1=%x\n"
  2104.         db    "c1=%c,  c2=%c\n"
  2105.         db    0
  2106.         dd    i1,i2,u1,u2,l1,l2,ul1,ul2,h1,c1,c2
  2107. ;
  2108. ;
  2109.         print
  2110.         db    "Testing scanf character skipping:",cr,lf,0
  2111.         lesi    sfstr2
  2112.         sscanf
  2113.         db    "%i, %i",0
  2114.         dd    i1,i2
  2115.         printf
  2116.         db    "i1=%i, i2=%i\n",0
  2117.         dd    i1, i2
  2118. ;
  2119. ;
  2120. ;****************************************************************************
  2121. ;
  2122. ;
  2123. ;
  2124. ; Testing the PUTC routines here.
  2125. ;
  2126. ; The following code should print:
  2127. ;
  2128. ; aaa
  2129. ; aaa
  2130. ; aaa
  2131. ; aaaaaaaa
  2132. ;
  2133. ; aaaa
  2134. ; aaaaaaaa
  2135. ; aaaa
  2136. ;
  2137. ;
  2138.         mov    al, 'a'
  2139.         putc
  2140.         putc
  2141.         putc
  2142. ;
  2143.         putcr
  2144. ;
  2145.         putcstdout
  2146.         putcstdout
  2147.         putcstdout
  2148.         putcr
  2149. ;
  2150.         putcbios
  2151.         putcbios
  2152.         putcbios
  2153.         putcr
  2154. ;
  2155.         mov    di, cs
  2156.         mov    es, di
  2157.         lea    di, dblchars
  2158.         setoutadrs
  2159. ;
  2160.         putc
  2161.         putc
  2162.         putc
  2163.         putc
  2164.         putcr
  2165. ;
  2166.         getoutadrs
  2167.         cmp    di, offset dblchars
  2168.         jne    badtest
  2169.         mov    di, es
  2170.         cmp    di, seg dblchars
  2171.         jne    badtest
  2172. ;
  2173.         mov    di, seg sl_putcstdout
  2174.         mov    es, di
  2175.         lea    di, sl_putcstdout
  2176.         pushoutadrs
  2177.         putc
  2178.         putc
  2179.         putc
  2180.         putc
  2181.         putcr
  2182. ;
  2183.         popoutadrs
  2184.         putc
  2185.         putc
  2186.         putc
  2187.         putc
  2188.         putcr
  2189.         popoutadrs
  2190.         cmp    di, offset dblchars
  2191.         jne    badtest
  2192.         mov    di, es
  2193.         cmp    di, seg dblchars
  2194.         jne    badtest
  2195. ;
  2196.         putc
  2197.         putc
  2198.         putc
  2199.         putc
  2200.         putcr
  2201.         jmp    short goodtest
  2202. ;
  2203. badtest:    print
  2204.         db    "GetOutAdrs or PopOutAdrs did not return "
  2205.         db    "the proper address",cr,lf,0
  2206. ;
  2207. GoodTest:
  2208. ;
  2209. ;
  2210. ;****************************************************************************
  2211. ;
  2212. ; Test the remaining print routines here
  2213. ;
  2214.         print
  2215.         db    "This is a test of the print routine",cr,lf,0
  2216. ;
  2217.         print
  2218.         db    0
  2219. ;
  2220.         print
  2221.         db    "So is this!",cr,lf,0
  2222. ;
  2223.         lesi    TestString0
  2224.         puts
  2225. ;
  2226.         print
  2227.         db    "Hex value 0xfa output by PutH: ",0
  2228.         mov    al, 0fah
  2229.         puth
  2230. ;
  2231.         print
  2232.         db    cr,lf,"Hex value 0xfa12 output by PutW: ",0
  2233.         mov    ax, 0fa12h
  2234.         putw
  2235. ;
  2236.         print
  2237.         db    cr,lf,"Decimal value 0xffff output by puti: ",0
  2238.         mov    ax, 0ffffh
  2239.         puti
  2240.         print    
  2241.         db    cr,lf,"Decimal value 1 output by puti: ",0
  2242.         mov    ax, 1
  2243.         puti
  2244. ;
  2245.         print
  2246.         db    cr,lf,"Unsigned value 0ffffh output by putu: ",0
  2247.         mov    ax, 0ffffh
  2248.         putu
  2249.         print
  2250.         db    cr,lf,"Unsigned value 1 output by putu: ",0
  2251.         mov    ax, 1
  2252.         putu
  2253. ;
  2254.         print
  2255.         db    cr,lf,"Long value 0ffff1234 output by putL: ",0
  2256.         mov    ax, 1234h
  2257.         mov    dx, 0ffffh
  2258.         putl
  2259.         print    
  2260.         db    cr,lf,"Long value 01234ffff output by putL: ",0
  2261.         mov    dx, 1234h
  2262.         mov    ax, 0ffffh
  2263.         putl
  2264. ;
  2265.         print
  2266.         db    cr,lf,"Unsigned long value 1234ffff output by "
  2267.         db    "putUL: ",0
  2268.         putul
  2269.         print
  2270.         db    cr,lf,"Unsigned long value 0ffff1234 output by "
  2271.         db    "putUL: ",0
  2272.         mov    dx, 0ffffh
  2273.         mov    ax, 1234h
  2274.         putUL
  2275.         putcr
  2276. ;
  2277.         mov    cx, 10
  2278. islp1:        print
  2279.         db    "Outputting -2567 using a field width of ",0
  2280.         mov    ax, cx
  2281.         puti
  2282.         print
  2283.         db    " **",0
  2284.         mov    ax, -2567
  2285.         putisize
  2286.         print
  2287.         db    "** w/PutISize",cr,lf,0
  2288.         loop    islp1
  2289. ;
  2290.         mov    cx, 10
  2291. islp2:        print
  2292.         db    "Outputting -2567 using a field width of ",0
  2293.         mov    ax, cx
  2294.         puti
  2295.         print
  2296.         db    " **",0
  2297.         mov    ax, -2567
  2298.         putusize
  2299.         print
  2300.         db    "** w/PutUSize",cr,lf,0
  2301.         loop    islp2
  2302. ;
  2303.         mov    cx, 10
  2304. islp3:        print
  2305.         db    "Outputting -2567 using a field width of ",0
  2306.         mov    ax, cx
  2307.         puti
  2308.         print
  2309.         db    " **",0
  2310.         mov    ax, -2567
  2311.         mov    dx, 0ffffh
  2312.         putlsize
  2313.         print
  2314.         db    "** w/PutLSize",cr,lf,0
  2315.         loop    islp3
  2316.         print
  2317.         db    "Outputting 0ff001234h using PutLSize: ",0
  2318.         mov    dx, 0ff00h
  2319.         mov    ax, 1234h
  2320.         mov    cx, 10
  2321.         PutLSize
  2322.         putcr
  2323. ;
  2324.         mov    cx, 10
  2325. islp4:        print
  2326.         db    "Outputting -2567 using a field width of ",0
  2327.         mov    ax, cx
  2328.         puti
  2329.         print
  2330.         db    " **",0
  2331.         mov    ax, -2567
  2332.         mov    dx, 0ffffh
  2333.         putulsize
  2334.         print
  2335.         db    "** w/PutULSize",cr,lf,0
  2336.         loop    islp4
  2337.         print
  2338.         db    "Outputting 0ff001234h using PutULSize: ",0
  2339.         mov    dx, 0ff00h
  2340.         mov    ax, 1234h
  2341.         mov    cx, 10
  2342.         PutULSize
  2343.         putcr
  2344. ;
  2345. ;****************************************************************************
  2346. ;
  2347. ; Testing the PRINTF routine:
  2348. ;
  2349.         printf
  2350.         db    "This is a test of the printf routine w/o any "
  2351.         db    "operands.\n"
  2352.         db    "It tests the esc characters \\n, \\r, \\b, \\t, "
  2353.         db    "\0x0d, and \\\\.\n"
  2354.         db    "Test of \\r:\n"
  2355.         db    "Old line.\rNew line.\n"
  2356.         db    "Test of \t\ttab.\n"
  2357.         db    "Test of backspace\b\b\b\b\bs p a c e\n"
  2358.         db    "Test of return using \\0x0d:\n"
  2359.         db    "Old line.\0x0dNew line.\n\n",0
  2360. ;
  2361.         printf
  2362.         db    cr,lf
  2363.         db    "Test of integer output formats (using I):\n"
  2364.         db    "\%d\t\t-\t*%d*\n"
  2365.         db    "\%10d\t\t-\t*%10d*\n"
  2366.         db    "\%-10d\t\t-\t*%-10d*\n"
  2367.         db    "\%\\*10d\t\t-\t*%\*10d*\n"
  2368.         db    "\%\-\\*10d\t\t-\t*%-\*10d*\n"
  2369.         db    "\%^d\t\t-\t*%^d*\n"
  2370.         db    "\%10^d\t\t-\t*%10^d*\n"
  2371.         db    "\%-10^d\t\t-\t*%-10^d*\n"
  2372.         db    "\%\\*10^d\t\t-\t*%\*10^d*\n"
  2373.         db    "\%\-\\*10^d\t-\t*%-\*10^d*\n"
  2374.         db    0
  2375.         dd    i,i,i,i,i,pi,pi,pi,pi,pi
  2376. ;
  2377.         printf
  2378.         db    cr,lf
  2379.         db    "Test of unsigned integer output formats (using U):\n"
  2380.         db    "\%u\t\t-\t*%u*\n"
  2381.         db    "\%10u\t\t-\t*%10u*\n"
  2382.         db    "\%-10u\t\t-\t*%-10u*\n"
  2383.         db    "\%\\*10u\t\t-\t*%\*10u*\n"
  2384.         db    "\%\-\\*10u\t\t-\t*%-\*10u*\n"
  2385.         db    "\%^u\t\t-\t*%^u*\n"
  2386.         db    "\%10^u\t\t-\t*%10^u*\n"
  2387.         db    "\%-10^u\t\t-\t*%-10^u*\n"
  2388.         db    "\%\\*10^u\t\t-\t*%\*10^u*\n"
  2389.         db    "\%\-\\*10^u\t-\t*%-\*10^u*\n"
  2390.         db    0
  2391.         dd    u,u,u,u,u,pu,pu,pu,pu,pu
  2392. ;
  2393.         printf
  2394.         db    cr,lf
  2395.         db    "Test of unsigned long output formats (using UL):\n"
  2396.         db    "\%ul\t\t-\t*%lu*\n"
  2397.         db    "\%15lu\t\t-\t*%15lu*\n"
  2398.         db    "\%-15lu\t\t-\t*%-15lu*\n"
  2399.         db    "\%\\*15lu\t\t-\t*%\*15lu*\n"
  2400.         db    "\%\-\\*15lu\t-\t*%-\*15lu*\n"
  2401.         db    "\%^lu\t\t-\t*%^lu*\n"
  2402.         db    "\%15^lu\t\t-\t*%15^lu*\n"
  2403.         db    "\%-15^lu\t\t-\t*%-15^lu*\n"
  2404.         db    "\%\\*15^lu\t-\t*%\*15^lu*\n"
  2405.         db    "\%\-\\*15^lu\t-\t*%-\*15^lu*\n"
  2406.         db    0
  2407.         dd    ul,ul,ul,ul,ul,pul,pul,pul,pul,pul
  2408. ;
  2409.         printf
  2410.         db    cr,lf
  2411.         db    "Test of long output formats (using L):\n"
  2412.         db    "\%ld\t\t-\t*%ld*\n"
  2413.         db    "\%15ld\t\t-\t*%15ld*\n"
  2414.         db    "\%-15ld\t\t-\t*%-15ld*\n"
  2415.         db    "\%\\*15ld\t\t-\t*%\*15ld*\n"
  2416.         db    "\%\-\\*15ld\t-\t*%-\*1ld*\n"
  2417.         db    "\%^ld\t\t-\t*%^ld*\n"
  2418.         db    "\%15^ld\t\t-\t*%15^ld*\n"
  2419.         db    "\%-15^ld\t\t-\t*%-15^ld*\n"
  2420.         db    "\%\\*15^ld\t-\t*%\*15^ld*\n"
  2421.         db    "\%\-\\*15^ld\t-\t*%-\*15^ld*\n"
  2422.         db    0
  2423.         dd    l,l,l,l,l,pl,pl,pl,pl,pl
  2424. ;
  2425.         printf
  2426.         db    cr,lf
  2427.         db    "Test of hexadecimal output (byte) using I:\n"
  2428.         db    "\%h\t\t-\t*%h*\n"
  2429.         db    "\%5h\t\t-\t*%5h*\n"
  2430.         db    "\%-5h\t\t-\t*%-5h*\n"
  2431.         db    "\%\\*5h\t\t-\t*%\*5h*\n"
  2432.         db    "\%\-\\*5h\t\t-\t*%-\*5h*\n"
  2433.         db    "\%^h\t\t-\t*%^h*\n"
  2434.         db    "\%5^h\t\t-\t*%5^h*\n"
  2435.         db    "\%-5^h\t\t-\t*%-5^h*\n"
  2436.         db    "\%\\*5^h\t\t-\t*%\*5^h*\n"
  2437.         db    "\%\-\\*5^h\t\t-\t*%-\*5^h*\n"
  2438.         db    0
  2439.         dd    i,i,i,i,i,pi,pi,pi,pi,pi
  2440. ;
  2441.         printf
  2442.         db    cr,lf
  2443.         db    "Test of hexadecimal output (word) using I:\n"
  2444.         db    "\%x\t\t-\t*%x*\n"
  2445.         db    "\%5x\t\t-\t*%5x*\n"
  2446.         db    "\%-5x\t\t-\t*%-5x*\n"
  2447.         db    "\%\\*5x\t\t-\t*%\*5x*\n"
  2448.         db    "\%\-\\*5x\t\t-\t*%-\*5x*\n"
  2449.         db    "\%^x\t\t-\t*%^x*\n"
  2450.         db    "\%5^x\t\t-\t*%5^x*\n"
  2451.         db    "\%-5^x\t\t-\t*%-5^x*\n"
  2452.         db    "\%\\*5^x\t\t-\t*%\*5^x*\n"
  2453.         db    "\%\-\\*5^x\t\t-\t*%-\*5^x*\n"
  2454.         db    0
  2455.         dd    i,i,i,i,i,pi,pi,pi,pi,pi
  2456. ;
  2457.         printf
  2458.         db    cr,lf
  2459.         db    "Test of hexadecimal output (long) using UL:\n"
  2460.         db    "\%lx\t\t-\t*%lx*\n"
  2461.         db    "\%15lx\t\t-\t*%15lx*\n"
  2462.         db    "\%-15lx\t\t-\t*%-15lx*\n"
  2463.         db    "\%\\*15lx\t\t-\t*%\*15lx*\n"
  2464.         db    "\%\-\\*15lx\t-\t*%-\*15lx*\n"
  2465.         db    "\%^lx\t\t-\t*%^lx*\n"
  2466.         db    "\%15^lx\t\t-\t*%15^lx*\n"
  2467.         db    "\%-15^lx\t\t-\t*%-15^lx*\n"
  2468.         db    "\%\\*15^lx\t-\t*%\*15^lx*\n"
  2469.         db    "\%\-\\*15^lx\t-\t*%-\*15^lx*\n"
  2470.         db    0
  2471.         dd    ul,ul,ul,ul,ul,pul,pul,pul,pul,pul
  2472. ;
  2473.         printf
  2474.         db    cr,lf
  2475.         db    "Test of character output using S:\n"
  2476.         db    "\%c\t\t-\t*%c*\n"
  2477.         db    "\%5c\t\t-\t*%5c*\n"
  2478.         db    "\%-5c\t\t-\t*%-5c*\n"
  2479.         db    "\%\\*5c\t\t-\t*%\*5c*\n"
  2480.         db    "\%\-\\*5c\t\t-\t*%-\*5c*\n"
  2481.         db    "\%^c\t\t-\t*%^c*\n"
  2482.         db    "\%5^c\t\t-\t*%5^c*\n"
  2483.         db    "\%-5^c\t\t-\t*%-5^c*\n"
  2484.         db    "\%\\*5^c\t\t-\t*%\*5^c*\n"
  2485.         db    "\%\-\\*5^c\t\t-\t*%-\*5^c*\n"
  2486.         db    0
  2487.         dd    s,s,s,s,s,ps,ps,ps,ps,ps
  2488. ;
  2489.         printf
  2490.         db    cr,lf
  2491.         db    "Test of string output using s:\n"
  2492.         db    "\%s\t\t-\t*%s*\n"
  2493.         db    "\%15s\t\t-\t*%15s*\n"
  2494.         db    "\%-15s\t\t-\t*%-15s*\n"
  2495.         db    "\%\\*15s\t\t-\t*%\*15s*\n"
  2496.         db    "\%\-\\*15s\t\t-\t*%-\*15s*\n"
  2497.         db    "\%^s\t\t-\t*%^s*\n"
  2498.         db    "\%15^s\t\t-\t*%15^s*\n"
  2499.         db    "\%-15^s\t\t-\t*%-15^s*\n"
  2500.         db    "\%\\*15^s\t\t-\t*%\*15^s*\n"
  2501.         db    "\%\-\\*15^s\t-\t*%-\*15^s*\n"
  2502.         db    0
  2503.         dd    s,s,s,s,s,ps,ps,ps,ps,ps
  2504. ;
  2505. ;****************************************************************************
  2506. ;
  2507. ; Test the input routines here.
  2508. ;
  2509.         print
  2510.         db    "Testing GETC- Press any key: ",0
  2511.         getc
  2512.         print
  2513.         db    cr,lf,"You pressed: '",0
  2514.         putc
  2515.         print
  2516.         db    "' : ",0
  2517.         putw
  2518.         print
  2519.         db    cr,lf,"Testing GetcStdIn- Press any key:",0
  2520.         GetcStdIn
  2521.         print
  2522.         db    cr,lf,"You pressed: '",0
  2523.         putc
  2524.         print
  2525.         db    "' : ",0
  2526.         putw
  2527.         print
  2528.         db    cr,lf,"Testing GetcBIOS- Press any key:",0
  2529.         getcBIOS
  2530.         print
  2531.         db    cr,lf,"You pressed: '",0
  2532.         putc
  2533.         print
  2534.         db    "' : ",0
  2535.         putw
  2536. ;
  2537.         print
  2538.         db    cr,lf,"Redirecting input, reading: ",0
  2539.         lesi    cseg:ReturnA
  2540.         SetInAdrs
  2541.         getc
  2542.         print
  2543.         db    cr,lf,"Getc returned: '",0
  2544.         putc
  2545.         print
  2546.         db    "' : ",0
  2547.         putw
  2548.         print
  2549.         db    cr,lf,"Pushing address, changing to 'B': ",0
  2550.         lesi    cseg:ReturnB
  2551.         PushInAdrs
  2552.         getc
  2553.         print
  2554.         db    cr,lf,"Getc returned: '",0
  2555.         putc
  2556.         print
  2557.         db    "' : ",0
  2558.         putw
  2559.         print
  2560.         db    cr,lf,"Popping address: ",0
  2561.         PopInAdrs
  2562.         cmp    di, offset ReturnB
  2563.         jne    BadPopIn
  2564.         mov    di, es
  2565.         cmp    di, seg ReturnB
  2566.         je    GoodPopIn
  2567. BadPopIn:    print
  2568.         db    cr,lf,"Did not return the proper address",cr,lf,0
  2569. GoodPopIn:    print
  2570.         db    cr,lf,"Popping address again, should read from kbd: "
  2571.         db    0
  2572.         PopInAdrs
  2573.         getc
  2574.         print
  2575.         db    cr,lf,"Getc returned: '",0
  2576.         putc
  2577.         print
  2578.         db    "' : ",0
  2579.         putw
  2580.         putcr
  2581. ;
  2582. ;****************************************************************************
  2583. ;
  2584. ; Test GETS here:
  2585. ;
  2586.         print
  2587.         db    "Testing GETS, enter a line of text: ",0
  2588.         gets
  2589.         jnc    goodgets
  2590.         print
  2591.         db    "Bad gets call",cr,lf,0
  2592. ;
  2593. goodgets:    print
  2594.         db    "You entered: ",0
  2595.         puts
  2596.         putcr
  2597. ;
  2598. ;
  2599. ;***************************************************************************
  2600. ;
  2601. ;
  2602. ;
  2603. Quit:        mov     ah, 4ch
  2604.         int     21h
  2605. ;
  2606. ;
  2607. Main        endp
  2608. ;
  2609. ;
  2610. dblchars    proc    far
  2611.         putcstdout
  2612.         putcstdout
  2613.         ret
  2614. dblchars    endp
  2615. ;
  2616. ;
  2617. ReturnA        proc    far
  2618.         mov    ax, "A"
  2619.         ret
  2620. ReturnA        endp
  2621. ;
  2622. ReturnB        proc    far
  2623.         mov    ax, "B"
  2624.         ret
  2625. ReturnB        endp
  2626. ;
  2627. ;
  2628. ; Printset- Prints the characters in the set passed in es:di
  2629. ;
  2630. PrintSet    proc
  2631.         push    es
  2632.         push    ds
  2633.         push    di
  2634.         push    si
  2635.         push    dx
  2636.         push    ax
  2637. ;
  2638.         mov    dx, es        ;dx:si := es:di
  2639.         mov    si, di
  2640. ;
  2641.         createsets
  2642.         copyset
  2643. PrLoop:        rmvitem
  2644.         cmp    al, 0
  2645.         jz    PrDone
  2646.         putc
  2647.         jmp    PrLoop
  2648. ;
  2649. PrDone:        free
  2650.         pop    ax
  2651.         pop    dx
  2652.         pop    si
  2653.         pop    di
  2654.         pop    ds
  2655.         pop    es
  2656.         ret
  2657. PrintSet    endp
  2658. ;
  2659. ;
  2660. ; Putfpacc- Prints the floating point accumulator:
  2661. ;
  2662. Putfpacc    proc    near
  2663.         assume    ds:StdGrp
  2664.         push    ds
  2665.         push    ax
  2666.         mov    ax, StdGrp
  2667.         mov    ds, ax
  2668.         call    Putspace
  2669.         call    Putspace
  2670.         mov    al, StdGrp:fpacc
  2671.         puth
  2672.         call    Putspace
  2673.         mov    al, StdGrp:fpacc
  2674.         puth
  2675.         call    Putspace
  2676.         mov    al, StdGrp:fpacc+1
  2677.         puth
  2678.         call    Putspace
  2679.         mov    al, StdGrp:fpacc+2
  2680.         puth
  2681.         call    Putspace
  2682.         mov    al, StdGrp:fpacc+3
  2683.         puth
  2684.         call    Putspace
  2685.         mov    al, StdGrp:fpacc+4
  2686.         puth
  2687.         call    Putspace
  2688.         mov    al, StdGrp:fpacc+5
  2689.         puth
  2690.         call    Putspace
  2691.         mov    al, StdGrp:fpacc+6
  2692.         puth
  2693.         call    Putspace
  2694.         mov    al, StdGrp:fpacc+7
  2695.         puth
  2696.         call    Putspace
  2697.         call    Putspace
  2698.         mov    al, StdGrp:fpacc+8
  2699.         puth
  2700.         call    Putspace
  2701.         mov    al, StdGrp:fpacc+9
  2702.         puth
  2703.         call    Putspace
  2704.         call    Putspace
  2705.         mov    al, StdGrp:fpacc+10
  2706.         puth
  2707. ;
  2708.         pop    ax
  2709.         pop    ds
  2710.         ret
  2711. PutFpacc    endp
  2712.         assume    ds:dseg
  2713. ;
  2714. PutSpace    proc    near
  2715.         push    ax
  2716.         mov    al, " "
  2717.         putc
  2718.         pop    ax
  2719.         ret
  2720. PutSpace    endp
  2721. ;
  2722. cseg            ends
  2723. ;
  2724. ;
  2725. ; Allocate a reasonable amount of space for the stack (2k).
  2726. ;
  2727. sseg        segment    para stack 'stack'
  2728. stk        db    256 dup ("stack   ")
  2729. sseg        ends
  2730. ;
  2731. ;
  2732. ;
  2733. ; zzzzzzseg must be the last segment that gets loaded into memory!
  2734. ;
  2735. zzzzzzseg    segment    para public 'zzzzzz'
  2736. LastBytes    db    16 dup (?)
  2737. heap        db    1024 dup (?)
  2738. zzzzzzseg    ends
  2739.         end    Main
  2740.